package newPan3d.ui
{
	import _Pan3D.base.Focus3D;
	
	import _me.Scene_data;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Vector3D;
	import flash.display.Loader;
	import flash.net.URLRequest;
	
	public class MapView extends Sprite
	{

		private var _mapData:BitmapData=new BitmapData(200,200,false,0xffffff)
		private var _mcmap:Bitmap
		private var _roadArray:Array=new Array()
		private var _lineMc:Sprite=new Sprite();
		private var _selfPoint:Sprite;
		private var _loader:Loader;
		
		public function MapView() {
			
		
			_mcmap=new Bitmap()
			this.addChild(_mcmap)
			_loadMapPic();
			this.addChild(_lineMc);
			addPoints();
			this.addEventListener(Event.ENTER_FRAME,onEnterFrame)
		}
		private  function _loadMapPic():void
		{
			_loader=new Loader;
			_loader.load(new URLRequest(Scene_data.fileRoot+"ground/texture/mappic.jpg"));
			_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadOK);
		
			
			

		}
		protected  function onLoadOK(event:Event):void
		{
			var loader:Loader = Loader(event.target.loader);
			var image:Bitmap = Bitmap(loader.content);
			_mcmap.bitmapData=image.bitmapData;
		}
		
		
		private function addPoints():void
		{
			_selfPoint=new Sprite()
			_selfPoint.graphics.beginFill(0x3ff,1);
			_selfPoint.graphics.drawCircle(-1,-1,2);
			_selfPoint.graphics.endFill();
			addChild(_selfPoint);
		}
		public function drawLoadLine(roadArr:Vector.<Vector3D>):void
		{
			_lineMc.graphics.clear();
			_lineMc.graphics.lineStyle(1,0x4433cc,1);
			_lineMc.graphics.moveTo( _selfPoint.x, _selfPoint.y);
			
			if(roadArr){
			for(var k:int=0;k< roadArr.length;k++){
				var tempV:Vector3D=roadArr[k];
				_lineMc.graphics.lineTo(tempV.x,tempV.z);
				}
			}
		
		}
		
		protected function onEnterFrame(event:Event):void
		{
			// TODO Auto-generated method stub
			var focus3D:Focus3D= Scene_data.focus3D
			_selfPoint.x=focus3D.x/5;
			_selfPoint.y=focus3D.z/5;
		}

		
	}
}